package edu.neusoft.android.yuejian14.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;

import java.util.List;

import edu.neusoft.android.yuejian14.Const_Pic;
import edu.neusoft.android.yuejian14.R;
import edu.neusoft.android.yuejian14.javabean.Video;
import edu.neusoft.android.yuejian14.viewHolder.VideoViewHolder;


public class VideoListAdapter extends BaseAdapter  {
    public VideoListAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_video, parent, false);
        VideoViewHolder viewHolder = new VideoViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
       Video getvideolistByClubId= (Video) data.get(position);
        VideoViewHolder viewHolder = (VideoViewHolder) holder;
        String videoaddress = getvideolistByClubId.getVideoaddress();
        Uri uri = Uri.parse(Const_Pic.BASE_URL+videoaddress);
        viewHolder.videoView.setMediaController(new MediaController(context));
        viewHolder.videoView.setVideoURI(uri);
        viewHolder.videoView.requestFocus();
        //viewHolder.videoView.start();
    }
}
